Skip to content

Improve error reporting when non mandatory options are misconfigured#1294

Closed
jayychoi wants to merge 1 commit intospring-projects:mainfrom
jayychoi:improve-optional-misconfigured
Closed

Improve error reporting when non mandatory options are misconfigured#1294
jayychoi wants to merge 1 commit intospring-projects:mainfrom
jayychoi:improve-optional-misconfigured

Conversation

@jayychoi
Copy link
Copy Markdown

This PR improves error reporting for optional options that are misconfigured.

  • Fail fast for optional options without default value: CommandFactoryBean now validates that optional options must have a default value. If an optional option is declared without a default value, the application fails at startup with a clear error message instead of logging a warning at runtime.

  • Option without value already handled: This is already handled by DefaultCommandParser since commit 78d1a47, which throws an IllegalArgumentException when parsing such input.

Changes

  • CommandFactoryBean: Added validation to reject optional options without default values at command registration time
  • CommandFactoryBeanTests: Added unit tests for the new validation logic

Resolves #1245

Resolves spring-projects#1245

Signed-off-by: Jay Choi <jayyoungchoi22@gmail.com>
@fmbenhassine
Copy link
Copy Markdown
Contributor

This PR was valid based on my comment here: #1245 (comment).

However, as explained in #1245 (comment), things have changed since then and we now accept non-mandatory options without default values. Therefore, this PR is not up-to-date anymore. I am closing it.

Thank you for your contribution anyway 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve error reporting when non mandatory options are misconfigured or incorrectly specified at runtime

2 participants